(function() {
	var $ = require(L('$')), _ = require(L('_'));

	var partial = {};
	partial.mydesires_product_image = function(image) {
		var pui = $.layout('mydesires/partial/image');
		$.cache_image(image, pui.image);
		$.on('load', pui.image, function() {
			pui.loading.visible = false;
			$.mask(false);
		});
		return pui.view;
	};
	partial.mydesire_ugd_image = function(image, callBack) {
		var pui = $.layout('mydesires/partial/ugd_image');
		pui.image.hires = true;
		$.cache_image(image, null, function(e) {
			var height = $.resizeImageByWidth(e, 112).height;
			pui.image.image = e;
			pui.view.height = height + 8;
			pui.image.height = height;
			callBack && callBack(pui.view.height);
		});
		$.on('load', pui.image, function() {
			pui.loading.visible = false;
			$.mask(false);
		});
		return pui.view;
	};

	partial.empty_row = function() {
		var pui = $.layout('partial/empty_row');
		return pui.row;
	};

	partial.scan_and_take_photo = function() {
		var pui = $.layout('partial/scan_and_take_photo');
		$.tap(pui.btnScan, function() {
			$.barcode().scan();
		});
		$.tap(pui.btnTakePhoto, function() {
			if ($.is_debug()) {
				$.photo().select(function(e) {
					var width = $.ugdImageWidth() || 360;
					var quality = $.ugdImageQuality() || 0.9;
					var image = $.compressAndResize(e, width, quality);
					//$.win('ugd/preview').update(image);
					$.win('ugd/form').create(image);
				});
				return;
			}
			$.photo().take(function(e) {
				var width = $.ugdImageWidth() || 360;
				var quality = $.ugdImageQuality() || 0.9;
				var image = $.compressAndResize(e, width, quality);
				//$.win('ugd/preview').update(image);
				$.win('ugd/form').create(image);
			});
		});
		return pui.view;
	};

	module.exports = partial;
})();

